const { mysql } = require('../qcloud')

module.exports = async (ctx) => {
	const { openid } = ctx.request.body

	try {
		await mysql('records')
			.where('openid',openid)
			.del()
		//执行成功返回到前端的数据
		ctx.state.data = {
			code: 0,
			msg: "success"
		}
		console.log("执行成功")
	} catch (err) {
		console.log("执行错误：",err)
		//执行失败返回到前端的数据
		ctx.state = {
			code: -1,
			data: {
				msg: "清除失败" + err.sqlMessage
			}
		}
	}
}